package com.lagou;

import com.lagou.config.RequestLimit;
import com.lagou.filter.BlackListFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@SpringBootApplication
//@EnableEurekaClient
@RefreshScope
public class GatewayApplication implements CommandLineRunner {
    @Autowired
    BlackListFilter blackListFilter;
    @Autowired
    RequestLimit requestLimit;
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class,args);
    }

    @Override
    public void run(String... args) throws Exception {
        new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(blackListFilter, 1, 10, TimeUnit.SECONDS);
    }
}
